<?php
namespace app\admin\controller;

use app\admin\model\Admin;
use think\Controller;

class Login extends Controller
{
    public function index()
    {
        return $this->fetch();
    }

    public function checklogin()
    {
    	$data = input('post.');


		$admin = Admin::get([
			'username' =>$data['username'],
			'password'=>md5($data['password'])
		]);

		if($admin){
			session('admin',$admin);
			$this->success("登录成功");
		}else{
			$this->error('用户或者密码不正确');
		}
    }

    public function loginout()
    {
    	session('admin',null);

    	$this->success("退出成功",url('admin/login/index'));
    }
}
